/*
 * Copyright (c) 2006, 2022, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

/**
 * <p>Project: jse2204 - Test2
 * <p>Powered by webrx On 2022-09-21 13:10:57
 * 已知一个int数组, 编程从数组中获取最大数
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Test2 {
    public static void main(String[] args) {
        int values[] = {1, 2, 9, 3, 4, 5};
        int max = getMax(values);
        System.out.printf("The MAX values: %d\n", max);
    }

    public static int getMax(int[] values) {
        int tmp = Integer.MIN_VALUE;
        if (null != values) {
            tmp = values[0];
            for (int i = 0; i < values.length; i++) {
                if (tmp < values[i]) {
                    tmp = values[i];
                }
            }
        }
        return tmp;
    }
}
